<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script language="javascript" src="/js/jquery-1.8.0.min.js"></script>
    <title><?=$title?> - 票付通分销平台</title>
</head>
<body>
<link rel="stylesheet" href="/css/aliceui.min.css"/>
<link rel="stylesheet" href="/css/resetui.css"/>
<link rel="stylesheet" href="/css/page.css"/>
<link rel="stylesheet" href="css/list.css"/>
<div class="wrap">
    <input name="gid" type="hidden" value="<?=$id?>"/>
    <h2 class="title">
        <?=$title?>
        <?if(isset($_GET['group'])):?>
        <button type="button" id="select_applyer">添加集团成员</button>
        <?endif;?>
    </h2>
    <div class="ui-table-container">
        <table class="ui-table ui-table-noborder"><!-- 可以在class中加入ui-table-inbox或ui-table-noborder分别适应不同的情况 -->
        <thead>
        <tr>
            <th>记录ID</th>
            <th>生成时间</th>
            <th>企业名称</th>
            <th>联系人</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?if(count($relation_list)):?>
        <?foreach($relation_list as $list):?>
        <tr data-parent="<?=$list['parent_id']?>" data-son="<?=$list['son_id']?>">
            <td><?=$list['id']?></td>
            <td><?=$list['rectime']?></td>
            <td><?='['.$LD[$list['dtype']].']-'.$list['dname']?>(ID:<?=$list['account']?>)</td>
            <td><?=$list['cname'].'('.$list['mobile'].')'?></td>
            <td><?=$LS[$list['status']]?></td>
            <td>
                <?if($list['status']==0):?>
                <a class="hanlder-relation" data-hanlder="1" href="javascript:">删除</a>
                <?else:?>
                <a class="hanlder-relation" data-hanlder="2" href="javascript:">重新关联</a>
                <?endif;?>
            </td>
        </tr>
        <?endforeach;else:?>
        <tr>
            <td colspan="8">还未建立过关系！</td>
        </tr>
        <?endif;?>
        </tbody>
    </table>
    </div>
</div>
<script>
    $(document).ready(function(){
        $("#select_applyer").on('click', function(){
            var gid = $('input[name="gid"]').val();
            $("body").append('<iframe style="width: 96%; height:504px; border: 2px solid #CCC; margin:0 0 20px 20px;" src="http://www.12301.cc/admin/mems.php?gid='+gid+'&dtype=0&status=0"></iframe>');
        });
        $("tbody").on('click', 'a.hanlder-relation', function(){
            var handler = $(this).attr('data-hanlder'),
                msg = {1:'您确定要删除吗？',2:'您确定要重新关联吗？'};
            if(!confirm(msg[handler])) return false;
            var parent = $(this).parents('tr'),
                    params = {
                        action: 'RelationHanler',
                        parent_id : parent.attr('data-parent'),
                        son_id : parent.attr('data-son'),
                        ship_type: 1,
                        handler:handler
                    };
            $.post('/call/jh_mem.php', params, function(res){
                alert(res.msg);
                if(res.status=='ok') {
                    parent.hide();
                }
            },'json');
        });
    });
</script>
</body>
</html>
